#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 100;
vector<PII>ans;
struct node
{
	int a, b;
}S[100];
LL n;
LL a[N];
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		//ans.clear();
		int cnt1 = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%lld", &a[i]);
		}
		int cnt = 0;
		int idx = 1;
		if (a[1] < 0) {
			for (int i = 1; i <= n; i++) {
				if (a[i] > 0) {
					idx = i;
					break;
				}
			}
			//cout<<"idx==="<<idx<<endl;
			if (idx == 1) {
				idx = n + 1;
			}
			for (int i = idx - 1; i >= 2; i--) {
				while (a[i] < a[i - 1]) {
					//ans.push_back({ i - 1,i });
					S[++cnt1] = { i - 1,i };
					a[i - 1] += a[i];
					cnt++;
				}
			}
		}
		//cout<<"idx==="<<idx<<endl;
		for (int i = idx; i <= n; i++) {
			if (a[i] < a[i - 1]) {
				while (a[i] < a[i - 1]) {
					//ans.push_back({ i,i - 1 });
					S[++cnt1] = { i,i - 1 };
					a[i] += a[i - 1];
					//cout << "a[i]==" << a[i] << endl;
					cnt++;
				}
			}
		}
		// for (int i = 1; i <= n; i++) {
		// 	cout << a[i] << " ";
		// }
		// cout<<endl;
		printf("%d\n", cnt1);
		/*for (PII x : ans) {
			cout << x.first << " " << x.second << endl;
		}*/
		for (int i = 1; i <= cnt1; i++) {
			// << S[i].a << " " << S[i].b << endl;
			printf("%d %d\n", S[i].a, S[i].b);
		}
	}
	return 0;
}